/*
*  Copyright (C) 2009  Peter Kist & Jan Ripke
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>

#include <logic/engine/Types.h>
#include <logic/engine/Engine.h>

namespace galaxy {
    namespace logic {
        namespace engine {

            class Engine;

            /** the engine manager controls the different 'logic' engines that are used in the game.
            * Examples are the galaxy engine, starsystem engine and planetary engine.
            * The Engine manager enables transitions between the engines and house-keeping and/or cleanup.
            */
            class EngineManager
            {
                /** singleton engine manager */
                static EngineManager * m_Singleton;

                /** the engine container (map). */
                EngineMap m_EngineMap;

                /** the currently active engine */
                EnginePtr m_CurrentEngine;

            public:
                EngineManager(void);
                ~EngineManager(void);

                /** register the specified engine.
                * @param engine The engine to register.
                * @return true upon success, false upon failure.
                */
                bool registerEngine (EnginePtr& engine);
                /** unregister the specified engine.
                */
                EnginePtr unregisterEngine (Engine::Name engineName);
                void unregisterEngine(EnginePtr& engine);

                EnginePtr getCurrentEngine ();
                bool changeEngine (Engine::Name engineName);

                static EngineManager& singleton () { return *m_Singleton; };
            };

        } // namespace engine
    } // namespace logic
} // namespace galaxy
